<?php

namespace App\Http\Model;

use App\Http\Traits\DelayTask;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;

/**
 * 萌新聊天记录
 */
class NoviceChatLog extends Base
{
    use DelayTask;

    /**
     * 表名字
     *
     * @var string
     */
    protected $table = 'novice_chat_log';

    /**
     * 构造函数
     *
     * @param array $attributes
     */
    public function __construct(array $attributes = [])
    {
        parent::__construct($this->table, $attributes);
    }

    /**
     * 写记录
     *
     * @return bool|int
     */
    public function addLog($user_id, $toUserId, $chatType, $content)
    {
        return DB::table($this->table)->insert([
            'user_id' => $user_id,
            'to_user_id' => $toUserId,
            'chat_type' => $chatType,
            'content' => base64_encode($content),
        ]);
    }

}
